# 面向对象特性
# 二、继承

# class 类名(父类名)
class Phone:
    IMEI = None
    producer = None

    def call_by_4g(self):
        print("4g通话")


class Phone2023(Phone):
    face_id = "10001"

    def call_by_5g(self):
        print("2023年新功能: 5g通话")


phone = Phone2023()
print(phone.producer)
phone.call_by_4g()
phone.call_by_5g()


# 多继承使用','分隔
class NFCReader:
    nfc_type = "5"
    producer = "R"

    def read_card(self):
        print("NFC读卡")

    def write_card(self):
        print("NFC写卡")


class RemoteControl:
    rc_type = "红外遥控"

    def control(self):
        print("开启红外遥控")


class MyPhone(Phone, NFCReader, RemoteControl):
    pass  # 使用pass补全语法


phone = MyPhone()
phone.call_by_4g()
phone.read_card()
phone.control()
print(phone.producer)  # 同名变量保留第一个继承的值


# 复写父类成员
class Phone2(Phone):
    producer = "HHH"

    def call_by_4g(self):
        print("开启CPU单核模式")

        # 复写后调用父类成员
        print(f"父类的厂商是: {Phone.producer}")
        Phone.call_by_4g(self)  # 需要传入self

        # 另一种方法 使用super()
        print(super().producer)
        super().call_by_4g()  # 不用传入self

        print("使用4g网络进行通话")


phone = Phone2()
phone.call_by_4g()
print(phone.producer)
